import time

import requests

headers = {
    "referer": "https://www.iqiyi.com/",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
}
url = "https://mesh.if.iqiyi.com/portal/lw/videolib/data"
count = 0
page = 0
while True:
    page += 1
    params = {
        "uid": "",
        "passport_id": "",
        "ret_num": "60",
        "version": "12.112.20682",
        "device_id": "f0f58dd33cc7c5a84b01d7bad789db53",
        "channel_id": "2",
        "page_id": page,
        "os": "",
        "conduit_id": "",
        "vip": "0",
        "auth": "",
        "recent_selected_tag": "",
        "ad": "[{\"lm\":\"5\",\"ai\":\"5\",\"fp\":\"6\",\"sei\":\"S7c680f970a5a817a0d4c74cba129f815\",\"position\":\"library\"}]",
        "adExt": "{\"r\":\"1.1.5-ares6-pure\"}",
        "dfp": "a08d166cb33ee042918b5fbe7c91831e4987afadd752994e4237bc61c777824d00",
        "filter": "{\"mode\":\"24\"}"
    }
    response = requests.get(url, headers=headers, params=params)
    if response.json()["has_next"] == 0:
        break
    count += 1
    print(response.json())
    print(response, count)
    time.sleep(1)
